#ifndef P2P_BASE_RAWTRANSPORT_H_
#define P2P_BASE_RAWTRANSPORT_H_

#include <string>
#include "transport.h"

#if defined(FEATURE_ENABLE_PSTN)

namespace cricket
{
	// Implements a transport that only sends raw packets, no STUN. As a result,
	// it cannot do pings to determine connectivity, so it only uses a single port
	// that it thinks will work.
	class RawTransport : public Transport, public TransportParser
	{
	public:
		RawTransport(base::Thread* signaling_thread,
			base::Thread* worker_thread,
			const std::string& content_name,
			PortAllocator* allocator);
		virtual ~RawTransport();

		virtual bool ParseCandidates(SignalingProtocol protocol,
			const buzz::XmlElement* elem,
			const CandidateTranslator* translator,
			Candidates* candidates,
			ParseError* error);
		virtual bool WriteCandidates(SignalingProtocol protocol,
			const Candidates& candidates,
			const CandidateTranslator* translator,
			XmlElements* candidate_elems,
			WriteError* error);

	protected:
		// Creates and destroys raw channels.
		virtual TransportChannelImpl* CreateTransportChannel(int component);
		virtual void DestroyTransportChannel(TransportChannelImpl* channel);

	private:
		// Parses the given element, which should describe the address to use for a
		// given channel. This will return false and signal an error if the address
		// or channel name is bad.
		bool ParseRawAddress(const buzz::XmlElement* elem, 
			base::SocketAddress* addr, ParseError* error);

		friend class RawTransportChannel; // For ParseAddress.

		DISALLOW_EVIL_CONSTRUCTORS(RawTransport);
	};
}

#endif

#endif	// P2P_BASE_RAWTRANSPORT_H_